//
//  MUserAccount.swift
//  iOSweibo
//
//  Created by lzm on 16/5/14.
//  Copyright © 2016年 lzm. All rights reserved.
//

import UIKit

//"access_token" = "2.00eltxdC0hS3Gr57d048a47eJy_4yB";
//"expires_in" = 157679999;
//"remind_in" = 157679999;
//uid = 2422818494;
class MUserAccount: NSObject ,NSCoding{

    var access_token : String?
    var expires_in : NSTimeInterval = 0
        {
        didSet
            {
                expiresDare = NSDate(timeIntervalSinceNow: expires_in)
            }
    }
    //过期时间,方便比较时间
    var expiresDare : NSDate?
    var uid : String?
    //用户名称 
    var screen_name :String?
    //用户头像
    var avatar_large :String?
    
    
    init(dict: [String: AnyObject]) {
        super.init()
        self .setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    
    //MARK:归档,解档
    required init?(coder aDecoder: NSCoder) {
        access_token = aDecoder.decodeObjectForKey("access_token") as? String
        expires_in = aDecoder.decodeDoubleForKey("expires_in")
        expiresDare = aDecoder.decodeObjectForKey("expiresDare") as? NSDate
        uid = aDecoder.decodeObjectForKey("uid") as? String
        screen_name = aDecoder.decodeObjectForKey("screen_name") as? String
        avatar_large = aDecoder.decodeObjectForKey("avatar_large") as? String
        
        
    }
    
    func encodeWithCoder(aCoder: NSCoder) {
        aCoder.encodeObject(access_token, forKey: "access_token")
        aCoder.encodeDouble(expires_in, forKey: "expires_in")
        aCoder.encodeObject(expiresDare, forKey: "expiresDare")
        aCoder.encodeObject(uid, forKey: "uid")
        aCoder.encodeObject(screen_name, forKey: "screen_name")
        aCoder.encodeObject(avatar_large, forKey: "avatar_large")
    }
    
    
}
